<% if false # the license inside this if block assertains to this file -%>
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
<% end -%>
<%= compile 'templates/license.erb' -%>

<%= lines(autogen_notice :ruby) -%>

require 'google/<%= prop_ns_dir -%>/property/base'

<% full_name = ['Google', product_ns, 'Property', 'Array'].join('::') -%>
module Google
  module <%= product_ns %>
    module Property
      # A Puppet property that can compare its values
      class Array < Google::<%= product_ns -%>::Property::Base
<%=
  lines(format([
                ["# Sets #{full_name} to match all elements, not any."],
                [
                  "# Sets #{full_name} to match all elements, not",
                  '# any.'
                ]
               ], 8))
-%>
        def self.match_all_array
          self.array_matching = :all
        end

        # When the user specifies an array for a property Puppet by default
        # ensures that at least 1 of the values match. This is useful when you
        # have various options and any match is good, e.g. various possible file
        # sources, say from Corp or Internet.
        #
        # However our arrays require that all values match so we define the
        # array_matching = :all to instruct Puppet to do this. This could have
        # been specified in the Puppet::Type, but putting it here makes it
        # simpler to not "forget" to define it.
        match_all_array

        def match_all?
          true
        end

        def self.api_munge(value)
          value
        end
      end
    end
  end
end
